$(function() {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = "http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false&callback";
  document.body.appendChild(script);
});

function initialize() {
	// Initialize default values
	var zoom = 3;
	var latlng = new google.maps.LatLng(37.4419, -100.1419);
	
	var myOptions = {
			zoom: zoom,
			center: latlng,
			mapTypeId: google.maps.MapTypeId.ROADMAP,
			scrollwheel: false
	}
	
	window.map = new google.maps.Map(document.getElementById("map"), myOptions);
	window.map.markers = new google.maps.MVCArray();
}

function add_marker(location,options){
	var marker = new google.maps.Marker({
		position: location, 
		map: window.map,
		draggable:false
	  });
	
	clear_map_markers();
	window.map.markers.push(marker);
	 var defaultOptions = $.extend( {
		 zoom: 13,
		 center: location,
		 mapTypeId: google.maps.MapTypeId.ROADMAP
	  }, options);
	
	window.map.setOptions(defaultOptions);
}

function clear_map_markers(){
	for(var i=0;i<window.map.markers.getLength();i++){
		window.map.markers.getAt(i).setMap(null);
	}
	
	window.map.markers.clear();
}




 